
fractorial = {0:1}
for i in range(1, 10):
    fractorial[i] = reduce(lambda a, b: a * b, range(1, i + 1))

i = 10
while True:
    si = str(i)
    if i > len(si) * fractorial[9]:
        break
    if i == sum(map(lambda c:fractorial.get(int(c)), si)):
        print i
    i += 1
print 'loop stopped at i = %d > %d * %d  = %d' % (i, len(si), fractorial[9], len(si) * fractorial[9])
pass